<?php
require_once('../../../inc/header.inc.php');
require_once(BX_DIRECTORY_PATH_INC.'design.inc.php');
require_once(BX_DIRECTORY_PATH_INC.'profiles.inc.php');
require_once(BX_DIRECTORY_PATH_INC.'utils.inc.php');

$db = mysql_connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASS);
mysql_query("SET NAMES 'utf8'");
if ($db==FALSE)
die ("errore di connessione");
mysql_select_db(DATABASE_NAME,$db) or die ("errore selezione database");

$verifica = "SELECT uri FROM sys_modules WHERE uri = 'ibdwemail'";
$exegui = mysql_query($verifica);
$num_ver = mysql_num_rows($exegui);

if($num_ver != 0) { include('../ibdwemail/email_notify.php'); }
$utente=(int)$_COOKIE['memberID'];
$user_like=$_POST['user_like'];

$idnotizia=$_POST['id_like'];
$idutente=$_POST['user_like'];
$attivaintegrazione = 0;
if(isset($_POST['phdlxid'])) { if($_POST['phdlxid']==0) { $phdlxid = 0; $typelement = 0; } else { $phdlxid = $_POST['phdlxid']; $attivaintegrazione = 1; if($_POST['typelement'] == 1) { $typelement = 'photo'; } } } 
$controllo="SELECT * FROM ibdw_likethis WHERE id_notizia='$idnotizia' AND id_utente='$idutente'";
$esegui=mysql_query($controllo);
$numeri=mysql_num_rows($esegui);
if ($user_like==$utente AND $numeri==0) 
{
 if($attivaintegrazione != 0) { $query="INSERT INTO ibdw_likethis (id_notizia,id_utente,ibdw_likethis.like,phdlxid,typelement) VALUES ('".$_POST['id_like']."', '".$_POST['user_like']."', '1', '".$phdlxid."','".$typelement."')"; }
 else { $query="INSERT INTO ibdw_likethis (id_notizia,id_utente,ibdw_likethis.like) VALUES ('".$_POST['id_like']."', '".$_POST['user_like']."', '1')"; }
 $result=mysql_query($query);
}

$proprietario = "SELECT id,sender_id FROM bx_spy_data WHERE id='$idnotizia'";
$esegui = mysql_query($proprietario);
$fetch = mysql_fetch_assoc($esegui);
$newpro = $fetch['sender_id'];

if($newpro != $utente AND $istruzione_1 == '1' AND $num_ver != 0 ) { email_notify('like_action',$newpro,$utente,$idnotizia); }

?>